/*
Copyright SecureKey Technologies Inc. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0
*/

package random

import (
	"math/rand"

	"git.cloud.inspur.com/ichain/ichain-sdk-go/pkg/providers/ichain"
)

// PickRandomNInodeConfigs 随机选取n个
func PickRandomNInodeConfigs(chInodes []ichain.ChainInode, n int) []ichain.InodeConfig {

	var result []ichain.InodeConfig
	for _, index := range rand.Perm(len(chInodes)) {
		result = append(result, chInodes[index].InodeConfig)
		if len(result) == n {
			break
		}
	}
	return result
}
